﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using appInterfaces;
using appDataContracts;

namespace appAdmin
{
    /// <summary>
    /// Logique d'interaction pour mainWindow.xaml
    /// </summary>
    public partial class loginWindow : Window
    {
        private myAdminService.AdminClient adminService = null;

        public loginWindow()
        {
            InitializeComponent();
            tbLogin.Text = "admin@exia.fr";
            tbPassword.Password = "admin";
        }

        private void btLogin_Click(object sender, RoutedEventArgs e)
        {
            adminService = new myAdminService.AdminClient();
            SerializedAdmin admin = adminService.adminLogin(tbLogin.Text, tbPassword.Password);

            if (admin != null)
            {
                this.Visibility = Visibility.Hidden;
                new AppWindow(admin, this.adminService).Show();
            }
            else
            {
                lblError.Content = "Mauvaises informations de login.";
            }
        }

        private void btQuit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
